﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<IEnumerable<TireBias.Models.TailModel.TailBias_DS>>" %>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
    Index
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <% var md = new TireBias.Models.TailModel.TailBias_DS();
    var second = new TireBias.Models.TailModel.TailBias_DS();
    var seqs="";
    if (Model.Count() > 0)
    {
       seqs= Model.First()._plandt + '-' + Model.First()._itemno;
       md= Model.First();
       if (Model.Count() > 1) second = Model.ElementAt(1);
    }
    %>
 
   <table class="shadow" style=" width: 98%">
      <% if (WinNemoLib.StrUtil.IsNotEmpty(md._Text))
         {%>
      <tr>
         <td class="cell" style="font-size: x-large;line-height: 30px; 
            padding: 5px; background-color: #C38DEC;" colspan="3">
            <%= md._Text%>
         </td>
      </tr>
      <%} %>
      <tr class="rowb">
         <td class="head cell text-right" style="padding: 10px 0px; width: 50%; vertical-align: top;">
            <table id="tbl1" width="98%">
               <tr class="rowa cell" id="rowh">
                  <td class="head" colspan="2">
                     USE PLY PLAN <span class="fontTh">ใช้แผนการตัดผ้าใบ</span>
                  </td>
               </tr>
               <tr class="rowb cell">
                  <td style="line-height: 40px!important; border: 1px solid #000; width: 40%">
                     PLY
                  </td>
                  <td style="line-height: 40px!important; border: 1px solid #000">
                     Actual
                  </td>
               </tr>
               <% if (WinNemoLib.StrUtil.IsNotEmpty(md._P1))
                  { %>
               <tr class="rowa cell">
                  <td style="line-height: 40px!important; border: 1px solid #000; width: 40%">
                     P1
                  </td>
                  <td style="line-height: 40px!important; border: 1px solid #000" id="sumP1">
                     &nbsp;
                  </td>
               </tr>
               <%} %>
               <% if (WinNemoLib.StrUtil.IsNotEmpty(md._P2))
                  { %><tr class="rowa cell">
               <td style="line-height: 40px!important; border: 1px solid #000; width: 40%">
                  P2
               </td>
               <td style="line-height: 40px!important; border: 1px solid #000" id="sumP2">
                  &nbsp;
               </td>
            </tr>
               <%} %>
               <% if (WinNemoLib.StrUtil.IsNotEmpty(md._P3))
                  { %><tr class="rowa cell">
               <td style="line-height: 40px!important; border: 1px solid #000; width: 40%">
                  P3
               </td>
               <td style="line-height: 40px!important; border: 1px solid #000" id="sumP3">
                  &nbsp;
               </td>
            </tr>
               <%} %>
               <% if (WinNemoLib.StrUtil.IsNotEmpty(md._P4))
                  { %><tr class="rowa cell">
               <td style="line-height: 40px!important; border: 1px solid #000; width: 40%">
                  P4
               </td>
               <td style="line-height: 40px!important; border: 1px solid #000" id="sumP4">
                  &nbsp;
               </td>
            </tr>
               <%} %>
                <tr class="rowa cell" style="background-color:#20B2AA">
               <td style="line-height: 40px!important; border: 1px solid #000; width: 40%">
                   TOTAL</td>
               <td style="line-height: 40px!important; border: 1px solid #000" id="total">
                   &nbsp;</td>
            </tr>
               </table>
            <br />
            <table id="tbl2" width="98%">
               <tr class="rowa cell">
                  <td class="head" colspan="2">
                     Now <span class="fontTh">(ปัจจุบัน)</span><input type="hidden" id="subItem"  />
                  </td>
               </tr>
               <tr style="text-align: center; font-size: 8em; font-weight: bolder;  line-height: 200px; ">
                  <td id="ply1" style="border:2px solid black !important;" >
                      <%= md._Ply1 %>
                     </td>
                  <td id="ply2" style="border:2px solid black !important;" >
                     <%= md._Ply2 %>
                  </td>
               </tr>
               <tr >
                  <td >&nbsp;</td><td >&nbsp;</td>
               </tr>
               
            </table>
         </td>
         <td style="vertical-align:top;">
            <table width="100%" style="height:100%">
            <tr> 
<td class="col cell" style="padding: 10px 0px; width: 25%;">
DATE-SEQ
<span class="fontTh">ล็อตที่ผลิต</span>
</td>
<td class="cell" id="seqDT">
<h3><%= md._plandt %>-<%=md._itemno %>-<%=md._sitemno%></h3>  
</td>
</tr>
 <tr class="rowb">
         <td class="col cell" style="padding: 10px 0px; width: 25%;">
            SIZE
            <span class="fontTh">ขนาดผ้าใบ</span>
         </td>
         <td class="cell" id="Td1">
         <h3> <%= md._sizes %></h3>  
         </td>
      </tr>
      <tr class="rowb">
         <td class="col cell" style="padding: 10px 0px; width: 25%;">
            FORMING
           
            <span class="fontTh">เครื่องที่สร้าง</span>
         </td>
         <td class="cell" id="Td2">
        <h3>   <%= md._forming %></h3> 
         </td>
      </tr>
     
      <tr class="rowb">
         <td class="col cell" style="padding: 10px 0px; width: 25%;">
            Topped Cord
            
            <span class="fontTh">ผ้าใบ</span>
         </td>
         <td class="cell" id="Td7">
         <h3>  <%= md._topcrdcd%></h3> 
         </td>
      </tr>
      <tr class="rowb">
         <td class="col cell" style="padding: 10px 0px; width: 25%;">
            Tire Cord Lot         
            <span class="fontTh">ล็อตผ้าใบ</span>
         </td>
         <td class="cell" id="Td8">
         <h3>  <%= md._toplot %></h3> 
         </td>
      </tr>
      <tr class="rowb">
         <td class="col cell" style="padding: 10px 0px; width: 25%;">
            Roll No
          
            <span class="fontTh">รถคันที่</span>
         </td>
         <td class="cell" id="Td9">
         <h3>  <%= md._toproll %></h3> 
         </td>
      </tr>
      <tr class="rowb">
         <td class="col cell" style="padding: 10px 0px; width: 25%;">
           Expired date
       
            <span class="fontTh">วันหมดอายุ</span>
         </td>
         <td class="cell">
         <h3>  <%= md._topexp %></h3> 
         </td>
      </tr>
      <tr class="rowb">
         <td class="col cell" style="padding: 10px 0px; width: 25%;">
         Length (M.)
            
            <span class="fontTh">ความยาว(เมตร)</span>
         </td>
         <td class="cell" >
         <h3>  <%= md._toplen %></h3> 
         </td>
      </tr>
       <% if (WinNemoLib.StrUtil.IsNotEmpty(md._P1) && (Convert.ToInt32(md._P1) > 0))
         { %>
      <tr class="rowb">
         <td class="col cell" style="padding: 10px 0px; width: 25%;">
            P1
          
            <span class="fontTh">ความยาวผ้าใบชั้นที่ 1 (มม.)</span>
         </td>
         <td class="cell" id="Td3">
     <h3>  <%= md._P1%></h3>     
         </td>
      </tr>
      <% } %>
      <% if (WinNemoLib.StrUtil.IsNotEmpty(md._P2) && (Convert.ToInt32(md._P2) > 0))
         { %>
      <tr class="rowb">
         <td class="col cell" style="padding: 10px 0px; width: 25%;">
            P2
            
            <span class="fontTh">ความยาวผ้าใบชั้นที่ 2 (มม.)</span>
         </td>
         <td class="cell" id="Td4">
        <h3>   <%= md._P2%></h3> 
         </td>
      </tr>
      <% } %>
      <% if (WinNemoLib.StrUtil.IsNotEmpty(md._P3) && (Convert.ToInt32(md._P3) > 0))
         { %>
      <tr class="rowb">
         <td class="col cell" style="padding: 10px 0px; width: 25%;">
            P3
         
            <span class="fontTh">ความยาวผ้าใบชั้นที่ 3 (มม.)</span>
         </td>
         <td class="cell" id="Td5">
           <h3> <%= md._P3%></h3>
         </td>
      </tr>
      <% } %>
      <% if (WinNemoLib.StrUtil.IsNotEmpty(md._P4) && (Convert.ToInt32(md._P4) > 0))
         { %>
      <tr class="rowb">
         <td class="col cell" style="padding: 10px 0px; width: 25%;">
            P4          
            <span class="fontTh">ความยาวผ้าใบชั้นที่ 4 (มม.)</span>
         </td>
         <td class="cell" id="Td6">
          <h3> <%= md._P4%></h3> 
         </td>
      </tr>
      <% } %>


            </table>
            
            </td>
      </tr>

   </table>
         <% if (WinNemoLib.StrUtil.IsNotEmpty(second._plandt))
         {%>
   <table width="98%" class="shadow">
      <tr class="rowa" style="background-color:#FFDF80">
         <td class="cell head"  style="font-size: x-large;line-height: 30px; padding: 5px; background-color: #C38DEC;">
            NEXT PLAN
             :
         </td>
         <td class="cell ">
         <%= second._topcrdcd %>
         </td>
           <td class="cell ">
         <%= second._sizes %>
         </td>
        <td class="cell">
         <%= second._forming %>
         </td>
         <%  if ((second._Ply1 == "P1") || (second._Ply2 == "P1"))
            { %>
        <td class="cell">P1</td>
         <% } %>
            <%  if ((second._Ply1 == "P2") || (second._Ply2 == "P2"))
            { %>
           <td class="cell">P2</td>
            <% } %>
         <%  if ((second._Ply1 == "P3") || (second._Ply2 == "P3"))
            { %>
          <td class="cell">P3</td>
         <% } %>
                <%  if ((second._Ply1 == "P4") || (second._Ply2 == "P4"))
            { %>
          <td class="cell">P4</td>
         
         <% } %>
          <td  class="cell"style="width:50%">
          <%= second._Text %>
             </td>
      </tr></table>
      <%} %>
      <input type="hidden" id="bias" value="<%= TireBias.Models.SessionBag.Current.biasno %>" />
      <input type="hidden" id="hdnSeQ" value="<%=seqs%>" />
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="FeaturedContent" runat="server">
    <section class="featured">
 <div class="content-wrapper" style="height:40px">
            <hgroup class="title float-left">
            <h1>Bias Tail Computer</h1>
                <h2  style="padding-left:55px;">BIAS NO.<%:TireBias.Models.SessionBag.Current.biasno %></h2>      
            
            </hgroup> 
            <hgroup class="title float-right">
            <h3>
            Name :
            <% if (Request.IsAuthenticated)
               { %>
            <%:  User.Identity.Name %>
            <% } %> </h3>
              
            </hgroup>   
 </div>
 </section>
</asp:Content>

<asp:Content ID="Content4" ContentPlaceHolderID="TableContent" runat="server">
      <div class="float-left" style="margin-left: 10px">
         <% using (Html.BeginForm("LogOff", "Account", FormMethod.Post, new { id = "logoutForm" }))
            { %>
         <%: Html.AntiForgeryToken() %>
                <input type="button" value="EXIT" class="btnFooter shadow" style="height: 70px; width: 120px; margin-left:10px;"
            onclick="javascript:window.close();" />
         <% } %>
         </div>
       <div class="float-left" style="margin-left:50px;">
        <input id="head" type="button" value="PLAN" class="btnFooter shadow" style="height: 70px; width: 120px; margin-left:30px;" />
        <input id="report" type="button" value="REPORT" class="btnFooter shadow" style="height: 70px; width: 120px; margin-left:30px; display:none;" />
      
        <input id="wast" type="button" value="WASTE" class="btnFooter shadow" style="height: 70px; width: 120px; margin-left:30px; display:none;" />
        <input id="mat" type="button" value="MAT TO MAT" class="btnFooter shadow" style="height: 70px; width: 120px; margin-left:30px;" />
      </div>
       <div  class="float-right " style="margin-right:10px;"> 
      
        <input id="next" type="button" value="NEXT"class="btnFooter shadow" style="height: 70px; width: 120px;" />
      </div>

      <div id="dialog-plan">
      <table class=" shadow fontTB "id="dataTbl" width="98%">
         <thead>
            <tr class="head">
               <td class="cell" style="width: 17%; " rowspan="2">
                  SEQ<br /><span class="fontTh">ลำดับ</span>
               </td>
               <td class="cell" style="width: 20%" rowspan="2">
                  TOPPED CORD<br /><span class="fontTh">ผ้าใบ</span>
               </td>
               <td class="cell" style="width: 15%" rowspan="2">
                  SIZE<br /><span class="fontTh">ขนาดผ้าใบ</span>
               </td>
               <td class="cell" colspan="4" align="center" style="border-bottom:1px solid #000000">
               <span class="fontTh">  ความยาวผ้าใบ</span> <span class="fontTh">(มม.)</span></td>
               <td class="cell" style="width: 15%; " rowspan="2">
                  FORMING<br /><span class="fontTh">ขนาดผ้าใบ</span>
               </td>
               <td class="cell" rowspan="2">
                  TEXT<br /><span class="fontTh">ข้อความ</span>
               </td>
            </tr>
            <tr class="head">
               <td class="cell" style="width: 10%;">
                  P1<br /><span class="fontTh">ชั้นที่ 1 </span>&nbsp;</td>
                 <td class="cell" style="width: 10%;">
                  P2<br /><span class="fontTh">ชั้นที่ 2 </span>&nbsp;</td>
                 <td class="cell" style="width: 10%;">
                  P3<br /><span class="fontTh">ชั้นที่ 3</span>
               </td>
                 <td class="cell" style="width: 10%;">
                  P4<br /><span class="fontTh">ชั้นที่ 4 </span>
               </td>
            </tr>
            <tr id="trHd" class="hide">
            <td class="cell" >&nbsp;</td>
            <td class="cell" >&nbsp;</td>
            <td class="cell" >&nbsp;</td>
               <td class="cell" style="width: 10%;">               
                  P1</td>
                 <td class="cell" style="width: 10%;">
                  P2</td>
                 <td class="cell" style="width: 10%;">
                  P3
               </td>
                 <td class="cell" style="width: 10%;">
                  P4
               </td>
               <td class="cell" >&nbsp;</td>   
               <td class="cell" >&nbsp;</td>
            </tr>
            
         </thead>
         <tbody></tbody>
         
      </table>
      </div>
</asp:Content>

<asp:Content ID="Content5" ContentPlaceHolderID="ScriptsSection" runat="server">
    <style type="text/css">
.col
{ font-weight:bolder;
   padding: 7px 0px 7px 100px !important; 
   width: 50% !important; 
   text-align: left !important;
   background-color:#ccc !important;
   line-height: 45px!important;
}
.text-center
{
    text-align:center;
}
.hide
{
    display:none;
}
.actived
{
    background-color: #20B2AA !important;
    color: White;
}

</style>

<script type="text/javascript">
    $(function () {

        $("#dialog-plan").dialog({
            width: 1200,
            height: 600,
            position: {
                my: 'center',
                at: 'center'
            },
            autoOpen: false,
            show: "blind",
            open: function (event, ui) {
                $.post('<%=Url.Action("Header_line","BiasTail") %>' + '?biasno=' + $("#bias").val()
                    , function (data) {
                        $("#dataTbl tbody").empty();
                        for (i = 0; i < data.length; i++) {
                            var seq = data[i]._Plandt + '-' + data[i]._Itemno;
                            var row = "rowb";
                            if (i % 2 == 0) {
                                row = "rowa";
                            }
                            var $tr = $("#trHd").clone();
                            $tr.removeClass("hide").removeAttr("id").addClass(row);
                            if (i == 0) {
                                $tr.addClass("actived");
                            }
                            $("td:eq(0)", $tr).text(seq).addClass("text-center");
                            $("td:eq(1)", $tr).text(data[i]._Topcrdcd);
                            $("td:eq(2)", $tr).text(data[i]._Size);
                            $("td:eq(3)", $tr).text(data[i]._P1).addClass("text-center");
                            $("td:eq(4)", $tr).text(data[i]._P2).addClass("text-center");
                            $("td:eq(5)", $tr).text(data[i]._P3).addClass("text-center");
                            $("td:eq(6)", $tr).text(data[i]._P4).addClass("text-center");
                            $("td:eq(7)", $tr).text(data[i]._Forming).addClass("text-center");
                            $("td:eq(8)", $tr).text(data[i]._Text);
                            $tr.appendTo($("#dataTbl tbody"));
                        }
                    }); //post
            }
        });

        //end dialog
        var seq = $("#hdnSeQ").val();
        $("#wast").click(function () {
            var nextURL = '<%= Url.Action("AddWaste","BIASWASTE") %>';
            nextURL += '?returnUrl=' + '<%= Url.Action("Index","BiasTail") %>' + '&biasno=' + $("#bias").val();
            window.location = nextURL
        });
        $("#report").click(function () {
            var nextURL = '<%= Url.Action("Export_Report","Table") %>' + '?biasno=' + $("#bias").val(); ;
            window.location = nextURL;
        });
        $("#mat").click(function () {
            var nextURL = '<%= Url.Action("MatToMat","MatToMat") %>';
            window.location = nextURL;
        });
        $("#head").click(function () {
            $("#dialog-plan").dialog("open");
        });

        if (seq != "") {
            $("#next").click(function () {
                var nextURL = '<%= Url.Action("GET_INF_STD","BiasTail") %>';
                window.location = nextURL;
            });



            $.post('<%=Url.Action("GET_USE","BiasHead")%>' + '?seq=' + seq + '&biasno=' + $("#bias").val(), function (data) {
                if (data.length > 0) {
                    $("#sumP1").text(data[0]._P1);
                    $("#sumP2").text(data[0]._P2);
                    $("#sumP3").text(data[0]._P3);
                    $("#sumP4").text(data[0]._P4);
                    var total = parseFloat(data[0]._P1) + parseFloat(data[0]._P2) + parseFloat(data[0]._P3) + parseFloat(data[0]._P4);
                    $("#total").text(total);

                }
            });
        }
    });

</script>
</asp:Content>
